package com.erp.ae.service.impl;

import com.erp.ae.domain.enums.AliExpressInterfaceEnum;
import com.erp.ae.service.IAeMediacenterService;
import com.global.iop.domain.Protocol;
import com.ruoyi.common.core.domain.R;
import com.erp.ae.utils.AeApiUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 商户订单Service业务层处理
 *
 * @author erp
 * @date 2023-03-09
 */
@RequiredArgsConstructor
@Service
public class IAeMediacenterServiceImpl implements IAeMediacenterService {


    @Override
    public R<Object> videoUploadByUR(Map<String, Object> map) {
        String storeId = (String) map.get("sellerId");
        //移除无用参数
        String accessToken = AeApiUtils.getToken(storeId);
        map.remove("storeId");
        String returnMsg =
                AeApiUtils.sendRequest(
                        AliExpressInterfaceEnum.uploadMediacenterByUrl.getCode(),
                        map,
                        Protocol.TOP,
                        accessToken
                );
        System.out.println(returnMsg);
        return R.ok(returnMsg);
    }

    @Override
    public R<Object> videoListPage(Map<String, Object> map) {
        //解析map
        String storeId = (String) map.get("sellerId");
        //移除无用参数
        map.remove(storeId);
        String accessToken = AeApiUtils.getToken(storeId);
        String returnMsg =
                AeApiUtils.sendRequestHttpMethodIsGet(
                        AliExpressInterfaceEnum.mediacenterListPage.getCode(),
                        map,
                        Protocol.TOP,
                        accessToken
                );
        System.out.println(returnMsg);
        return R.ok(returnMsg);
    }

    @Override
    public R<String> getByStorageName(Map<String, Object> map) {
        //解析map
        String storeId = (String) map.get("storeId");
        //移除无用参数
        map.remove(storeId);
        String accessToken = AeApiUtils.getToken(storeId);
        String returnMsg =
                AeApiUtils.sendRequestHttpMethodIsGet(
                        AliExpressInterfaceEnum.getByStorageName.getCode(),
                        map,
                        Protocol.TOP,
                        accessToken
                );
        System.out.println(returnMsg);
        return R.ok(returnMsg);
    }
}
